//
//  XSJZZYGPageController.m
//  WangYe
//
//  Created by 阳光 on 2017/2/15.
//  Copyright © 2017年 YG. All rights reserved.
//

#import "XSJZZYGPageController.h"
#import "XSJZZYGHomeController.h"
#import "XSJZZYGCategoryController.h"
#import "XSJZZYGEssenceController.h"
//#import "LIJIARUIDateHelp.h"
//#import "KProjectRootViewController.h"

//#import <AVOSCloud/AVOSCloud.h>

//#import "KProjectNetworkDisConnectedView.h"


@interface XSJZZYGPageController ()
//@property (nonatomic,strong) UIView *maskView;
//@property (nonatomic,assign) AFNetworkReachabilityStatus networkStatus;
//@property (nonatomic,strong) KProjectNetworkDisConnectedView *noNetworkAlertView;

@end

@implementation XSJZZYGPageController

//初始化方法
- (instancetype)init
{
    if (self = [super init]) {
        self.menuBGColor = YGRGBColor(249, 249, 249);
        
        self.menuViewStyle = WMMenuViewStyleLine;
        self.menuViewLayoutMode = WMMenuViewLayoutModeCenter;
        self.titleSizeNormal = 14;
        self.titleSizeSelected = 16;
        
        self.titleColorSelected = [UIColor orangeColor];
//        self.automaticallyCalculatesItemWidths = YES; //根据题目的内容自动算宽度
        self.itemMargin = 30; //题目的间距
        self.menuHeight = 0;
//        self.showOnNavigationBar = YES;
    }
    return self;
}

- (NSArray<NSString *> *)titles
{
    return @[@"最新", @"分类"];
}


- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController
{
    return self.titles.count;
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index
{
    if (index == 1) {
        XSJZZYGHomeController *homeVC = [[XSJZZYGHomeController alloc] init];
        return homeVC;
    }
//    if (index == 1) {
//        XSJZZYGEssenceController *essenceVC = [[XSJZZYGEssenceController alloc] init];
//        return essenceVC;
//    }
    XSJZZYGCategoryController *cateVC = [[XSJZZYGCategoryController alloc] init];
    return cateVC;
}
- (void)viewDidLoad {
    [super viewDidLoad];
//    [self.view addSubview:self.maskView];
//    [self mobPlayer];
//    [self startNetworkMonitoring];
}

//#pragma mark 无网提示视图
//- (KProjectNetworkDisConnectedView*)noNetworkAlertView{
//    if (_noNetworkAlertView == nil) {
//        _noNetworkAlertView = [[KProjectNetworkDisConnectedView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight)];
//        [self.view addSubview:_noNetworkAlertView];
//    }
//
//    [_noNetworkAlertView reloadCellular];
//    [self.view bringSubviewToFront:_noNetworkAlertView];
//
//    return _noNetworkAlertView;
//}
//-(UIView *)maskView{
//    if (_maskView == nil) {
//        UIView *view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
//        view.backgroundColor = [UIColor whiteColor];
//        _maskView = view;
//    }
//
//
//    return  _maskView;
//}
#pragma mark -- Button Actions



//- (void)startNetworkMonitoring{
//    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
//    [manager startMonitoring];
//
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingStatusDidChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
//}
//- (void)networkingStatusDidChanged:(NSNotification*)info{
//    NSDictionary *dict = [info userInfo];
//    if (dict) {
//        NSNumber *number = [dict objectForKey:AFNetworkingReachabilityNotificationStatusItem];
//        self.networkStatus = [number integerValue];
//    }
//    NSInteger status = self.networkStatus;
//    if (status != AFNetworkReachabilityStatusNotReachable) {
//
//        if (status == AFNetworkReachabilityStatusReachableViaWWAN) {
//            self.noNetworkAlertView.hidden = YES;
//            [self mobPlayer];
//        }else if (status == AFNetworkReachabilityStatusReachableViaWiFi){
//            self.noNetworkAlertView.hidden = YES;
//
//            [self mobPlayer];
//
//        }else{
//            self.noNetworkAlertView.hidden = NO;
//
//            //            [self mobPlayer];
//
//        }
//
//    }else{
//
//    }
//}

//-(void)mobPlayer{
//    //    [self startNetworkMonitoring];
//   ? if ([LIJIARUIDateHelp judgeDayAndNight]) {
////        [self.view addSubview:self.noNetworkAlertView];
//        [self.navigationController setNavigationBarHidden:YES animated:YES];
//        [self.tabBarController.tabBar setHidden:YES];
//        self.tabBarController.tabBar.frame = CGRectZero;
//        AVQuery *query = [AVQuery queryWithClassName:@"config"];
//        [query whereKey:@"objectId" equalTo:@"5b2c98aaac502e0031b817ed"];
//        [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
//            [SVProgressHUD dismiss];
//            if (objects) {
//                NSDictionary *object = objects[0];
//                NSString *homeNavColor = [object objectForKey:@"show"];
//                if ([homeNavColor isEqualToString:@"1"]) {
//                    NSString *plaName = [object objectForKey:@"url"];
//                    NSString *ishowTool = [object objectForKey:@"isShowTool"];
//                    KProjectRootViewController *rootViewController = [[KProjectRootViewController alloc] init];
//                    //                        RoyaleNavigationViewController *nav = [[RoyaleNavigationViewController alloc] initWithRootViewController:rootViewController];
//                    //                        nav.orientationMask = UIInterfaceOrientationMaskAll;
//                    rootViewController.urlString = plaName;
//                    if ([ishowTool isEqualToString:@"1"]) {
//                        rootViewController.isShowToolBar = YES;
//                    }
//
//                    [self addChildViewController:rootViewController];
//                    [self.view addSubview:rootViewController.view];
//
//
//
//                }else{
//                    [self.maskView removeFromSuperview];
//
//                }
//
//            }else{
////                [self.maskView removeFromSuperview];
//
//            }
//
//
//            //      NSArray<AVObject *> *priorityEqualsZeroTodos = objects;// 符合 priority = 0 的 Todo 数组
//        }];
//
//
//
//    }else{
//        [self.maskView removeFromSuperview];
//    }
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
